<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets the property doc comment</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionproperty.getdefaultvalue.html">« ReflectionProperty::getDefaultValue</a></li>
      <li style="float: right;"><a href="reflectionproperty.getmodifiers.html">ReflectionProperty::getModifiers »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionproperty.html">ReflectionProperty</a></li>
    <li>Gets the property doc comment</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionproperty.getdoccomment" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionProperty::getDocComment</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionProperty::getDocComment</span> &mdash; <span class="dc-title">Gets the property doc comment</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionproperty.getdoccomment-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionProperty::getDocComment</strong></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Gets the doc comment for a property.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionproperty.getdoccomment-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionproperty.getdoccomment-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The doc comment if it exists, otherwise <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionproperty.getdoccomment-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5245">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionProperty::getDocComment()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Str<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@var&nbsp;int&nbsp;&nbsp;The&nbsp;length&nbsp;of&nbsp;the&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$length&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$prop&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'Str'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'length'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$prop</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getDocComment</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(53) &quot;/**
     * @var int  The length of the string
     */&quot;
</pre></div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-5246">
    <p><strong>示例 #2 Multiple property declarations</strong></p>
    <div class="example-contents"><p>
     If multiple property declarations are preceeded by a single doc comment,
     the doc comment refers to the first property only.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Foo<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**&nbsp;@var&nbsp;string&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">$class&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Foo'</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperties</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$property</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$property</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">':&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$property</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getDocComment</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
a: &#039;/** @var string */&#039;
b: false
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionproperty.getdoccomment-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionproperty.getmodifiers.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::getModifiers()</a> - Gets the property modifiers</span></li>
    <li class="member"><span class="methodname"><a href="reflectionproperty.getname.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::getName()</a> - Gets property name</span></li>
    <li class="member"><span class="methodname"><a href="reflectionproperty.getvalue.html" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::getValue()</a> - Gets value</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>